<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Cellphonezone
 * @package     Cellphonezone_Repay
 * @author   $Id$
 */
require_once 'Mage/Paypal/controllers/StandardController.php';
class Cellphonezone_Repay_Paypal_StandardController extends Mage_Paypal_StandardController
{
   
    /**
     * When a customer chooses Paypal on Checkout/Payment page
     *
     */
    public function redirectAction()
    {
       $orderId = (int) $this->getRequest()->getParam('order_id');
       if (!$orderId)
       {
       	$this->_getRepay()->clear();//clear repay session
       	parent::redirectAction();
       }
       else 
       {
       		$this->_getRepay()->setRepay(true);//This is repay action
       		$this->_getRepay()->setOrderId($orderId);
       		$this->getResponse()->setBody($this->getLayout()->createBlock('repay/paypal_standard_redirect')->setOrderId($orderId)->toHtml());
       }
    }
    
	protected function _getRepay()
	{
		return Mage::getSingleton('repay/session');
	}
}
